import request from "@/utils/request.js"

/**
 * 获取推荐的答题应用
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryRecommendApps = () => {
  return request.get("/user/app/recommend")
}

/**
 * 获取在用户页的答题应用推荐
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryRecommendAppsToUserPage = () => {
  return request.get("/user/app/recommend/user")
}

/**
 * 获取答题应用详情
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryAppDetailById = (data) => {
  return request.get("/user/app/detail/" + data)
}

/**
 * 获取答题应用滚动分页列表
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryAppScrollingPageList = (data) => {
  return request.post("/user/app/scroll", data)
}

/**
 * 新增答题应用
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const saveApp = (data) => {
  return request.post("/user/app", data)
}

/**
 * 修改答题应用
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const updateApp = (data) => {
  return request.put("/user/app", data)
}

/**
 * 删除答题应用
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteApp = (data) => {
  return request.delete("/user/app/" + data)
}

/**
 * 修改答题应用分析权限
 * @param id
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const updateAppAnalysisAuth = (id, data) => {
  return request.post("/user/app/auth/" + id + '/' + data)
}


/**
 * 搜索答题应用
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const searchAppByValue = (data) => {
  return request.post("/user/app/search", data)
}

/**
 * 添加答题应用浏览记录
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addBrowseRecord = (data) => {
  return request.post("/user/app/browse/" + data)
}

/**
 * 获取答题应用浏览记录排行榜
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryBrowseTop = () => {
  return request.get("/user/app/browse")
}

/**
 * 获取我的答题应用
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryMyApp = (data) => {
  return request.post("/user/app/user/me", data)
}

/**
 * 获取其他答题应用分页列表
 * @param id
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryAppPageByUserId = (id, data) => {
  return request.post("/user/app/user/" + id, data)
}

/**
 * 收藏答题应用
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const collectApp = (data) => {
  return request.post("/user/app/collect/" + data)
}

/**
 * 取消收藏答题应用
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const cancelCollectApp = (data) => {
  return request.post("/user/app/uncollect/" + data)
}

/**
 * 分页查询收藏答题应用
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const pageQueryCollectAppOfBuilder = (data) => {
  return request.post("/user/app/collect/page", data)
}

/**
 * 分页查询收藏答题应用
 * @param id
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const pageQueryCollectAppByUserId = (id, data) => {
  return request.post("/user/app/collect/user/" + id, data)
}
